package net.qkl.chat.client.msghandler.chat;

import com.cn.common.core.model.Response;
import com.cn.common.core.model.ResultCode;
import com.cn.common.core.session.Session;
import com.cn.common.core.spi.ChatSpiLoader;
import net.qkl.chat.client.module.chat.handler.ChatHandler;
import net.qkl.chat.client.msg.MessageHandler;

/**
 * 私聊
 */
public class SingleChatHandler implements MessageHandler {

    private ChatHandler chatHandler;


    public SingleChatHandler() {
        this.chatHandler = ChatSpiLoader.load(ChatHandler.class);
    }

    @Override
    public void handle(Response packet, Session session) {
        if (packet.getStateCode() == ResultCode.SUCCESS) {
            chatHandler.privateChat(packet.getStateCode(), packet.getData());
        } else {
            chatHandler.privateChatError(packet.getStateCode(), packet);
        }
    }
}
